package com.bnz.service.impl;

import com.bnz.mapper.CourseMapper;
import com.bnz.mapper.ScoreMapper;
import com.bnz.mapper.StudentMapper;
import com.bnz.pojo.Student;
import com.bnz.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private CourseMapper courseMapper;
    @Autowired
    private ScoreMapper scoreMapper;
    // 1. 查询所有学生
    @Override
    public List<Student> findAll() {
        // 1.1 查询所有学生
        List<Student> students = studentMapper.selectAll();
        // 1.2 给每个学生找到对应的课程
       /* for (Student student : students) {
            student.setCname(courseMapper.selectByPrimaryKey(student.getCid()).getCname());
        }
        // 1.3 给每个学生找到对应分数
        for (Student student : students) {
            student.setScore(scoreMapper.selectByPrimaryKey(student.getCid()).getScore());
        }*/
        return students;
    }
}
